#此为自定义的频率类

from rest_framework.throttling import SimpleRateThrottle

class MySimple(SimpleRateThrottle):
    scope="send"

    #对手机验证码的发送做验证
    def get_cache_key(self, request, view):
        phone=request.query_params.get("phone")
        #如果没有传手机号,则不做限制
        if not phone:
            return None
        return 'throttle_%(scope)s_%(ident)s' % {"scope": self.scope, "ident": phone}
